package com.example.yiqiuser.controller;

import com.example.yiqiuser.entity.TDicArea;
import com.example.yiqiuser.service.TDicAreaService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @create by: 周文达 (3220083246@qq.com)
 * @description:
 * @create time: 2023/4/12 22:42
 * @return
 */
@RestController
@RequestMapping("area")
public class TDicAreaController extends BaseController {
    /**
     * 依赖注入
     */
    @Resource
    private TDicAreaService tDicAreaService;
    /**
     * 分页带参查询
     * @param page
     * @return
     */
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<TDicArea> page){
        return success(tDicAreaService.queryPage(page));
    }

    /**
     * 查询全部
     * @return
     */
    @PostMapping("queryAll")
    public  Result queryAll(){
        return success(tDicAreaService.queryAll());
    }

    /**
     * 根据id查询
     * @param code
     * @return
     */
    @GetMapping("queryById")
    public Result queryById(Integer code){
        return success(tDicAreaService.queryById(code));
    }

    /**
     * 添加
     * @param tDicArea
     * @return
     */
    @PostMapping("add")
    public  Result add(@RequestBody TDicArea tDicArea){
        return success(tDicAreaService.add(tDicArea));
    }

    /**
     * 更改
     * @param tDicArea
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody TDicArea tDicArea){
        return success(tDicAreaService.update(tDicArea));
    }

    /**
     * 根据id删除
     * @param code
     * @return
     */
    @GetMapping("deleteById")
    public Result deleteById(Integer code){
        return success(tDicAreaService.deleteById(code));
    }
}
